package com.mondo.financialwallet.data;

import com.mondo.financialwallet.data.entity.BasisResponseEntity;
import com.mondo.financialwallet.data.entity.CheckMessageCodeResultEntity;
import com.mondo.financialwallet.data.entity.ClearProductDetailsEntity;
import com.mondo.financialwallet.data.entity.FeedbackResponseEntity;
import com.mondo.financialwallet.data.entity.FindEntity;
import com.mondo.financialwallet.data.entity.GoogleValidatorEntity;
import com.mondo.financialwallet.data.entity.HoldProductDetailsEntity;
import com.mondo.financialwallet.data.entity.HoldProductListEntity;
import com.mondo.financialwallet.data.entity.HoldProductProfitDataEntity;
import com.mondo.financialwallet.data.entity.LoginUserInfoEntity;
import com.mondo.financialwallet.data.entity.MobilePrefixEntity;
import com.mondo.financialwallet.data.entity.MyTokenListEntity;
import com.mondo.financialwallet.data.entity.ProductDetailsEntity;
import com.mondo.financialwallet.data.entity.ProductListEntity;
import com.mondo.financialwallet.data.entity.ProductOrderListEntity;
import com.mondo.financialwallet.data.entity.SingleHoldProductProfitDataEntity;
import com.mondo.financialwallet.data.entity.TokenAddressEntity;
import com.mondo.financialwallet.data.entity.TokenTransactionRecordEntity;
import com.mondo.financialwallet.data.entity.UserAssetsEntity;
import com.mondo.financialwallet.data.entity.UserInfoEntity;
import com.mondo.financialwallet.data.entity.VersionUpdateEntity;
import com.mondo.financialwallet.data.entity.WalletAssetEntity;
import com.mondo.financialwallet.presentation.model.LoginUserInfoModel;
import com.mondo.financialwallet.data.net.WebService;
import com.mondo.financialwallet.data.params.FeedbackParams;
import com.mondo.financialwallet.data.params.LoginParams;
import com.mondo.financialwallet.data.params.RegisterParams;
import com.mondo.financialwallet.data.params.ResetPasswordParams;
import com.mondo.financialwallet.data.params.SendMessageParams;
import com.mondo.financialwallet.data.params.TokenTransferParams;

import java.io.File;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * 远程数据
 */
public class RemoteDataSource implements DataSource {

    @Override
    public void modifyAvatar(File portrait, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().modifyAvatar(
                MultipartBody.Part.createFormData("head_image", portrait.getName(),
                        RequestBody.create(MediaType.parse("multipart/form-data"), portrait))
        ).enqueue(new Callback<BasisResponseEntity>() {
            @Override
            public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                BasisResponseEntity response = new BasisResponseEntity();
                response.setStatus("failure");
                response.setMsg(t.getMessage());
                callback.onResult(response);
            }
        });
    }

    @Override
    public void versionUpdate(DataCallback<VersionUpdateEntity> callback) {
        WebService.Default.get().versionUpdate().enqueue(new Callback<VersionUpdateEntity>() {
            @Override
            public void onResponse(Call<VersionUpdateEntity> call, Response<VersionUpdateEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<VersionUpdateEntity> call, Throwable t) {
                VersionUpdateEntity entity = new VersionUpdateEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void customerFeedback(FeedbackParams params, DataCallback<FeedbackResponseEntity> callback) {
        WebService.CustomerService.get().customerFeedback(params).enqueue(new Callback<FeedbackResponseEntity>() {
            @Override
            public void onResponse(Call<FeedbackResponseEntity> call, Response<FeedbackResponseEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<FeedbackResponseEntity> call, Throwable t) {
                FeedbackResponseEntity entity = new FeedbackResponseEntity();
                entity.setStatus(1);
                entity.setMessage(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void holdProductList(DataCallback<HoldProductListEntity> callback) {
        WebService.Default.get().holdProductList().enqueue(new Callback<HoldProductListEntity>() {
            @Override
            public void onResponse(Call<HoldProductListEntity> call, Response<HoldProductListEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<HoldProductListEntity> call, Throwable t) {
                HoldProductListEntity entity = new HoldProductListEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void holdProductDetails(String orderNumber, DataCallback<HoldProductDetailsEntity> callback) {
        WebService.Default.get().holdProductDetails(orderNumber)
                .enqueue(new Callback<HoldProductDetailsEntity>() {
                    @Override
                    public void onResponse(
                            Call<HoldProductDetailsEntity> call, Response<HoldProductDetailsEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<HoldProductDetailsEntity> call, Throwable t) {
                        HoldProductDetailsEntity entity = new HoldProductDetailsEntity();
                        entity.setStatus("failure");
                        entity.setMsg(t.getMessage());
                        callback.onResult(entity);
                    }
                });
    }

    @Override
    public void clearProductDetails(String orderNumber, DataCallback<ClearProductDetailsEntity> callback) {
        WebService.Default.get().clearProductDetails(orderNumber)
                .enqueue(new Callback<ClearProductDetailsEntity>() {

                    @Override
                    public void onResponse(
                            Call<ClearProductDetailsEntity> call, Response<ClearProductDetailsEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<ClearProductDetailsEntity> call, Throwable t) {
                        ClearProductDetailsEntity entity = new ClearProductDetailsEntity();
                        entity.setStatus("failure");
                        entity.setMsg(t.getMessage());
                        callback.onResult(entity);
                    }
                });
    }

    @Override
    public void holdProductProfitData(String orderNumber, DataCallback<HoldProductProfitDataEntity> callback) {
        WebService.Default.get().holdProductProfitData()
                .enqueue(new Callback<HoldProductProfitDataEntity>() {

                    @Override
                    public void onResponse(
                            Call<HoldProductProfitDataEntity> call, Response<HoldProductProfitDataEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<HoldProductProfitDataEntity> call, Throwable t) {
                        HoldProductProfitDataEntity entity = new HoldProductProfitDataEntity();
                        entity.setStatus("failure");
                        entity.setMsg(t.getMessage());
                        callback.onResult(entity);
                    }
                });
    }

    @Override
    public void findDAppList(DataCallback<FindEntity> callback) {
        WebService.Default.get().findDAppList().enqueue(new Callback<FindEntity>() {
            @Override
            public void onResponse(Call<FindEntity> call, Response<FindEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<FindEntity> call, Throwable t) {
                FindEntity entity = new FindEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void productOrderList(DataCallback<ProductOrderListEntity> callback) {
        WebService.Default.get().productOrderList().enqueue(new Callback<ProductOrderListEntity>() {
            @Override
            public void onResponse(Call<ProductOrderListEntity> call, Response<ProductOrderListEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<ProductOrderListEntity> call, Throwable t) {
                ProductOrderListEntity entity = new ProductOrderListEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void googleValidator(DataCallback<GoogleValidatorEntity> callback) {
        WebService.Default.get().googleValidator().enqueue(new Callback<GoogleValidatorEntity>() {

            @Override
            public void onResponse(
                    Call<GoogleValidatorEntity> call, Response<GoogleValidatorEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<GoogleValidatorEntity> call, Throwable t) {
                GoogleValidatorEntity entity = new GoogleValidatorEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void bindGoogleValidator(String code, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().bindGoogleValidator(code)
                .enqueue(new Callback<BasisResponseEntity>() {
                    @Override
                    public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                        BasisResponseEntity result = new BasisResponseEntity();
                        result.setMsg(t.getMessage());
                        result.setStatus("failure");
                        callback.onResult(result);
                    }
                });
    }

    @Override
    public void clearProduct(String orderNumber, String code, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().clearProduct(orderNumber, code).enqueue(new Callback<BasisResponseEntity>() {
            @Override
            public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                BasisResponseEntity result = new BasisResponseEntity();
                result.setMsg(t.getMessage());
                result.setStatus("failure");
                callback.onResult(result);
            }
        });
    }

    @Override
    public void userInfo(DataCallback<UserInfoEntity> callback) {
        WebService.Default.get().userInfo().enqueue(new Callback<UserInfoEntity>() {
            @Override
            public void onResponse(Call<UserInfoEntity> call, Response<UserInfoEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<UserInfoEntity> call, Throwable t) {
                UserInfoEntity userInfoEntity = new UserInfoEntity();
                userInfoEntity.setStatus("failure");
                userInfoEntity.setMsg(t.getMessage());
                callback.onResult(userInfoEntity);
            }
        });
    }

    @Override
    public void userAssets(DataCallback<UserAssetsEntity> callback) {
        WebService.Default.get().userAssets().enqueue(new Callback<UserAssetsEntity>() {
            @Override
            public void onResponse(Call<UserAssetsEntity> call, Response<UserAssetsEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<UserAssetsEntity> call, Throwable t) {
                UserAssetsEntity userAssetsEntity = new UserAssetsEntity();
                userAssetsEntity.setStatus("failure");
                userAssetsEntity.setMsg(t.getMessage());
                callback.onResult(userAssetsEntity);
            }
        });
    }

    @Override
    public void myTokenList(DataCallback<MyTokenListEntity> callback) {
        WebService.Token.get().myTokenList().enqueue(new Callback<MyTokenListEntity>() {
            @Override
            public void onResponse(Call<MyTokenListEntity> call, Response<MyTokenListEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<MyTokenListEntity> call, Throwable t) {
                MyTokenListEntity entity = new MyTokenListEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void login(LoginParams params, DataCallback<LoginUserInfoModel> callback) {
        WebService.Default.get()
                .login(params.getAreaCode(), params.getAccount(), params.getPassword())
                .enqueue(new Callback<LoginUserInfoEntity>() {
                    @Override
                    public void onResponse(Call<LoginUserInfoEntity> call, Response<LoginUserInfoEntity> response) {
                        LoginUserInfoEntity userInfoEntity = response.body();
                        LoginUserInfoModel userInfoModel = new LoginUserInfoModel();

                        if (userInfoEntity.isSuccess()) {
                            LoginUserInfoEntity.DataBean data = userInfoEntity.getData();
                            userInfoModel.setToken(data.getToken());
                            userInfoModel.setUid(data.getUid());
                            userInfoModel.setBindGoogle(data.getIs_bind_google_code() == 1);
                            userInfoModel.setBindEmail(data.getIs_bind() == 1);
                            userInfoModel.setMobile(data.getMobile());
                            userInfoModel.setMobile_prefix(data.getMobile_prefix());
                        }

                        userInfoModel.setMsg(userInfoEntity.getMsg());
                        userInfoModel.setStatus(userInfoEntity.getStatus());
                        callback.onResult(userInfoModel);
                    }

                    @Override
                    public void onFailure(Call<LoginUserInfoEntity> call, Throwable t) {
                        LoginUserInfoModel userInfoModel = new LoginUserInfoModel();
                        userInfoModel.setStatus("failure");
                        userInfoModel.setMsg(t.getMessage());
                        callback.onResult(userInfoModel);
                    }
                });
    }

    @Override
    public void register(RegisterParams params, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get()
                .register(
                        params.getInvitationCode(),
                        params.getAuthCode(),
                        params.getMobileNumber(),
                        params.getPassword(),
                        params.getType(),
                        params.getAreaCode(),
                        params.getEmail())
                .enqueue(new RetrofitCallback<>(callback, new RetrofitCallback.OnFailure() {
                    @Override
                    public void onFailure(int code, String message) {

                    }
                }));
    }

    @Override
    public void productDetails(String id, DataCallback<ProductDetailsEntity> callback) {
        WebService.Default.get().productDetails(id).enqueue(new Callback<ProductDetailsEntity>() {
            @Override
            public void onResponse(Call<ProductDetailsEntity> call, Response<ProductDetailsEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<ProductDetailsEntity> call, Throwable t) {

            }
        });
    }

    @Override
    public void sendMessageCode(SendMessageParams params, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().sendMessageCode(params.getType(), params.getPrefix(), params.getValue())
                .enqueue(new RetrofitCallback<>(callback, new RetrofitCallback.OnFailure() {
                    @Override
                    public void onFailure(int code, String message) {

                    }
                }));
    }

    @Override
    public void transfer(
            TokenTransferParams params,
            DataCallback<BasisResponseEntity> callback) {
        WebService.Token.get()
                .transfer(params.getTokenId(), params.getAmount(), params.getToAddress(), params.getRemark())
                .enqueue(new Callback<BasisResponseEntity>() {
                    @Override
                    public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                        BasisResponseEntity result = new BasisResponseEntity();
                        result.setMsg(t.getMessage());
                        result.setStatus("failure");
                        callback.onResult(result);
                    }
                });
    }

    @Override
    public void tokenTransactionRecord(
            int page, String tokenId, String income, DataCallback<TokenTransactionRecordEntity> callback) {
        WebService.Token.get().tokenTransactionRecord(page, 10, income, tokenId)
                .enqueue(new Callback<TokenTransactionRecordEntity>() {
                    @Override
                    public void onResponse(
                            Call<TokenTransactionRecordEntity> call, Response<TokenTransactionRecordEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<TokenTransactionRecordEntity> call, Throwable t) {
                        t.printStackTrace();
                    }
                });
    }

    @Override
    public void bindNewMobileNumber(String mobile, String code, String prefix, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().bindNewMobileNumber(mobile, code, prefix)
                .enqueue(new Callback<BasisResponseEntity>() {
                    @Override
                    public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                        BasisResponseEntity result = new BasisResponseEntity();
                        result.setMsg(t.getMessage());
                        result.setStatus("failure");
                        callback.onResult(result);
                    }
                });
    }

    @Override
    public void bindEmail(String email, String code, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().bindEmail(email, code).enqueue(new Callback<BasisResponseEntity>() {

            @Override
            public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                BasisResponseEntity result = new BasisResponseEntity();
                result.setMsg(t.getMessage());
                result.setStatus("failure");
                callback.onResult(result);
            }
        });
    }

    @Override
    public void alterLoginPassword(
            String oldPassword, String newPassword, String code, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().alterLoginPassword(oldPassword, newPassword, code)
                .enqueue(new Callback<BasisResponseEntity>() {
                    @Override
                    public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                        BasisResponseEntity result = new BasisResponseEntity();
                        result.setMsg(t.getMessage());
                        result.setStatus("failure");
                        callback.onResult(result);
                    }
                });
    }

    @Override
    public void singleHoldProductProfitData(
            String orderNumber, DataCallback<SingleHoldProductProfitDataEntity> callback) {
        WebService.Default.get().singleHoldProductProfitData(orderNumber)
                .enqueue(new Callback<SingleHoldProductProfitDataEntity>() {

                    @Override
                    public void onResponse(
                            Call<SingleHoldProductProfitDataEntity> call,
                            Response<SingleHoldProductProfitDataEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<SingleHoldProductProfitDataEntity> call, Throwable t) {
                        SingleHoldProductProfitDataEntity entity = new SingleHoldProductProfitDataEntity();
                        entity.setStatus("failure");
                        entity.setMsg(t.getMessage());
                        callback.onResult(entity);
                    }
                });
    }

    @Override
    public void productList(DataCallback<ProductListEntity> callback) {
        WebService.Default.get().productList().enqueue(new Callback<ProductListEntity>() {
            @Override
            public void onResponse(Call<ProductListEntity> call, Response<ProductListEntity> response) {
                ProductListEntity products = response.body();
                callback.onResult(products);
            }

            @Override
            public void onFailure(Call<ProductListEntity> call, Throwable t) {

            }
        });
    }

    @Override
    public void walletAsset(DataCallback<WalletAssetEntity> callback) {
        WebService.Token.get().walletAsset().enqueue(new Callback<WalletAssetEntity>() {
            @Override
            public void onResponse(Call<WalletAssetEntity> call, Response<WalletAssetEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<WalletAssetEntity> call, Throwable t) {
                WalletAssetEntity entity = new WalletAssetEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void walletAssetAvailable(DataCallback<WalletAssetEntity> callback) {
        WebService.Token.get().walletAssetAvailable().enqueue(new Callback<WalletAssetEntity>() {
            @Override
            public void onResponse(Call<WalletAssetEntity> call, Response<WalletAssetEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<WalletAssetEntity> call, Throwable t) {
                WalletAssetEntity entity = new WalletAssetEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void tokenAddress(String tokenId, DataCallback<TokenAddressEntity> callback) {
        WebService.Token.get().tokenAddress(tokenId).enqueue(new Callback<TokenAddressEntity>() {
            @Override
            public void onResponse(Call<TokenAddressEntity> call, Response<TokenAddressEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<TokenAddressEntity> call, Throwable t) {
                TokenAddressEntity entity = new TokenAddressEntity();
                entity.setStatus("failure");
                entity.setMsg(t.getMessage());
                callback.onResult(entity);
            }
        });
    }

    @Override
    public void sendMessageByUser(String mobileNumber, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().sendMessageByUser(mobileNumber)
                .enqueue(new Callback<BasisResponseEntity>() {
                    @Override
                    public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                        BasisResponseEntity response = new BasisResponseEntity();
                        response.setStatus("failure");
                        response.setMsg(t.getMessage());
                        callback.onResult(response);
                    }
                });
    }

    @Override
    public void checkMessageCodeResult(
            String mobileNumber, String code, DataCallback<CheckMessageCodeResultEntity> callback) {
        WebService.Default.get().checkMessageCodeResult(mobileNumber, code)
                .enqueue(new Callback<CheckMessageCodeResultEntity>() {
                    @Override
                    public void onResponse(
                            Call<CheckMessageCodeResultEntity> call,
                            Response<CheckMessageCodeResultEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<CheckMessageCodeResultEntity> call, Throwable t) {
                        CheckMessageCodeResultEntity response = new CheckMessageCodeResultEntity();
                        response.setStatus("failure");
                        response.setMsg(t.getMessage());
                        callback.onResult(response);
                    }
                });
    }

    @Override
    public void alterPassword(ResetPasswordParams params, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get()
                .alterPassword(params.getPassword(), params.getMobile(), params.getToken(), params.getCode())
                .enqueue(new Callback<BasisResponseEntity>() {
                    @Override
                    public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                        BasisResponseEntity response = new BasisResponseEntity();
                        response.setStatus("failure");
                        response.setMsg(t.getMessage());
                        callback.onResult(response);
                    }
                });
    }

    @Override
    public void generateFinancingOrders(String goodsId, String amount, DataCallback<BasisResponseEntity> callback) {
        WebService.Token.get().generateFinancingOrders(goodsId, amount)
                .enqueue(new Callback<BasisResponseEntity>() {
                    @Override
                    public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                        BasisResponseEntity response = new BasisResponseEntity();
                        response.setStatus("failure");
                        response.setMsg(t.getMessage());
                        callback.onResult(response);
                    }
                });
    }

    @Override
    public void mobilePrefix(DataCallback<MobilePrefixEntity> callback) {
        WebService.Default.get().mobilePrefix().enqueue(new Callback<MobilePrefixEntity>() {
            @Override
            public void onResponse(Call<MobilePrefixEntity> call, Response<MobilePrefixEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<MobilePrefixEntity> call, Throwable t) {

            }
        });
    }


    @Override
    public void alterNickname(String nickname, DataCallback<BasisResponseEntity> callback) {
        WebService.Default.get().alterNickname(nickname).enqueue(new Callback<BasisResponseEntity>() {
            @Override
            public void onResponse(Call<BasisResponseEntity> call, Response<BasisResponseEntity> response) {
                callback.onResult(response.body());
            }

            @Override
            public void onFailure(Call<BasisResponseEntity> call, Throwable t) {
                BasisResponseEntity response = new BasisResponseEntity();
                response.setStatus("failure");
                response.setMsg(t.getMessage());
                callback.onResult(response);
            }
        });
    }
}